package org.puremvc.as3.multicore.test
{
	import org.flexunit.Assert;
	import org.puremvc.as3.multicore.core.MessagingConnector;
	import org.puremvc.as3.multicore.interfaces.IMessage;
	import org.puremvc.as3.multicore.patterns.facade.DummyFacade;
	import org.puremvc.as3.multicore.patterns.message.Message;
	
	public class FacadeTest
	{
		public function FacadeTest()
		{
		}
		
		protected var facade:DummyFacade;
		protected var facade2:DummyFacade;
		
		[Before]
		public function setUp():void {
			facade = DummyFacade.getInstance('DummyFacade');
			facade2 = DummyFacade.getInstance('DummyFacade2');
			var callback:MessagingConnector = new MessagingConnector(connector);
			facade.messagingConnector(callback);
		}

		[Test]
		public function testInitialize():void {
			Assert.assertTrue(facade.hasReView());
		}
		
		[Test]
		public function testInitialize2():void {
			Assert.assertFalse(facade.getMessageKey() == facade2.getMessageKey());
		}
		
		[Test(async,timeout="3000")]
		public function testEchoMessaging():void {
			var message:IMessage = new Message(DummyFacade.EXTERNAL_ECHO_MESSAGE, null);
			facade.receive(message);
		}
		
		private function connector(message:IMessage):void {
			Assert.assertNotNull(message);
			Assert.assertEquals("Message should be right", DummyFacade.EXTERNAL_ECHO_MESSAGE, message.getName());
		}

	}
}